The Dreamweaver JavaScript API > Selection functions > dom.nodeToOffsets() |
![]() ![]() ![]() |
Availability
Dreamweaver 3.0
Description
Gets the position of a specific node in the DOM tree, expressed as character offsets into the document's HTML source code. Valid for any document on a local drive.
Arguments
node
node
must be a tag, comment, or range of text that is a node in the tree returned by dreamweaver.getDocumentDOM()
.
Returns
An array containing two integers. The first integer is the character offset of the beginning of the tag, text, or comment; the second integer is the character offset of the end of the node, from the beginning of the HTML document.
Enabler
None.
Example
The following code selects the first image object in the current document:
var theDOM = dw.getDocumentDOM(); var theImg = theDOM.images[0]; var offsets = theDom.nodeToOffsets(theImg); theDom.setSelection(offsets[0], offsets[1]);
![]() ![]() ![]() |